package com.whatever;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ServicePracticeActivity extends Activity implements OnClickListener {
    
	public static final String TAG = "ServicesDemo";
	private Button buttonStart, buttonStop;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        buttonStart = (Button)findViewById(R.id.button0);
        buttonStop = (Button)findViewById(R.id.button1);
        
        buttonStart.setText("Start");
        buttonStop.setText("Stop");
        
        buttonStart.setOnClickListener(this);
        buttonStart.setOnClickListener(this);
    }

	public void onClick(View v) {
		switch(v.getId()) {
		case R.id.button0:
			Log.d(TAG, "onClick: starting service");
			startService(new Intent(this, MyService.class));
			break;
		case R.id.button1:
			Log.d(TAG, "onClick: stopping service");
			stopService(new Intent(this, MyService.class));
			break;
		}
	}
}